#pragma once

template <typename VAR_TYPE>
class CVarArray
{
public:
	CVarArray();
	virtual ~CVarArray();

	__forceinline VAR_TYPE operator [](intptr_t nIndex) const { return recs[nIndex]; }
	__forceinline VAR_TYPE& operator [](intptr_t nIndex) { return recs[nIndex]; }
	__forceinline VAR_TYPE get(intptr_t i) const{ return recs[i]; }
	__forceinline void put(intptr_t i, const VAR_TYPE v){ recs[i] = v; }
	__forceinline intptr_t size() const{ return count; }
	__forceinline bool isEmpty() const{ return count <= 0; }
	virtual bool add(const VAR_TYPE v);
	virtual bool add(const CVarArray<VAR_TYPE> &v);
	virtual void moveTo(CVarArray<VAR_TYPE> &dest);
	virtual bool del(intptr_t nIndex);
	virtual void clear();
	virtual intptr_t indexOf(const VAR_TYPE rec) const;
protected:
	bool CheckAdd(intptr_t n);

	VAR_TYPE *recs; intptr_t count;
};
